package org.iuniv.adb.patent.service;

import java.util.List;
import java.util.Map;

import org.iuniv.adb.patent.common.StringUtils;
import org.iuniv.adb.patent.dao.PatentDao;
import org.iuniv.adb.patent.dao.PatentDaoImpl;
import org.iuniv.adb.patent.model.Patent;

/**
 * @author vietcuong
 *
 */
public class PatentServiceImpl implements PatentService {

    private PatentDao patentDao;

    public PatentServiceImpl() {
        this.patentDao = new PatentDaoImpl();
    }

    /* (non-Javadoc)
     * @see org.iuniv.adb.patent.service.PatentService#findPatentByNum(java.lang.String)
     */
    @Override
    public Patent findPatentByNum(String patNumber) throws Exception {
        if (!StringUtils.isEmpty(patNumber)) {
            return patentDao.getPatent(patNumber);
        }
        return null;
    }

    /* (non-Javadoc)
     * @see org.iuniv.adb.patent.service.PatentService#findPatentByQuery(java.lang.String)
     */
    @Override
    public List<Patent> findPatentsByQuery(String queryParams) throws Exception {
        if (!StringUtils.isEmpty(queryParams)) {
            return patentDao.searchPatents(queryParams);
        }
        return null;
    }

    /* (non-Javadoc)
     * @see org.iuniv.adb.patent.service.PatentService#findPatentsByAdvOpts(java.lang.Object)
     */
    @Override
    public List<Patent> findPatentsByAdvOpts(Map<String, Object> advOpts) throws Exception {
        if (advOpts != null && advOpts.size() > 0) {
            return patentDao.searchPatents(advOpts);
        }
        return null;
    }
}
